package top.wyloop.intoeins.module.common.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.wyloop.intoeins.module.common.service.CaptchaService;
import top.wyloop.intoeins.response.Response;

/**
 * 验证码
 *
 * @author Wyatt6
 * @date 2025/1/23
 */
@Slf4j
@RestController
@RequestMapping("/api/common/captcha")
public class CaptchaController {
    @Autowired
    private CaptchaService captchaService;

    /**
     * 获取验证码
     *
     * @return {captchaKey 验证码KEY, captchaImage 验证码Base64图像}
     */
    @GetMapping("/getCaptcha")
    public Response getCaptcha() {
        log.info("[[获取验证码]]");
        return new Response().success().setData(captchaService.generateCaptcha());
    }
}
